// by Xeno
#define THIS_FILE "fn_handleattackgroups.sqf"
#include "x_setup.sqf"
private ["_grps", "_allunits", "_grp", "_numdown","_target","_target_array2","_dist"];

if (!isServer) exitWith {};

PARAMS_1(_grps);

__TargetInfo
_target = (_target_array2 select 0);
_dist = (_target_array2 select 2) * 2;
_allunits = [];
{
	_grp = _x;
	_allunits = [_allunits , units _grp] call FUNC(arrayPushStack);
	sleep 0.011;
} forEach _grps;

sleep 1.2123;

_numdown = 5;

while {!__XJIPGetVar(GVAR(mt_radio_down))} do {
	call FUNC(mpcheck);
	if ((_allunits call FUNC(GetAliveUnits)) < _numdown) exitWith {
		GVAR(c_attacking_grps) = [];
		GVAR(create_new_paras) = true;
	};
	{
		if (((leader _x) distance _target) > _dist) then {
			(leader _x) doMove _target;
			_grp setSpeedMode "FULL";
		};
	} forEach _grps;
	sleep 10.623;
};

_allunits = nil;
_grps = nil;
